<?php



namespace app\adminapi\controller\user;


use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\user\OpenvpnLists;
use app\adminapi\logic\user\OpenvpnLogic;
use app\adminapi\validate\user\OpenvpnValidate;


/**
 * openvpn控制器控制器
 * Class OpenvpnController
 * @package app\adminapi\controller\user
 */
class OpenvpnController extends BaseAdminController
{


    /**
     * @notes 获取openvpn控制器列表
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/07/04 15:15
     */
    public function lists()
    {
        return $this->dataLists(new OpenvpnLists());
    }


    /**
     * @notes 添加openvpn控制器
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/07/04 15:15
     */
    public function add()
    {
        $params = (new OpenvpnValidate())->post()->goCheck('add');
        $result = OpenvpnLogic::add($params);
        if (true === $result) {
            return $this->success('添加成功', [], 1, 1);
        }
        return $this->fail(OpenvpnLogic::getError());
    }


    /**
     * @notes 编辑openvpn控制器
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/07/04 15:15
     */
    public function edit()
    {
        $params = (new OpenvpnValidate())->post()->goCheck('edit');
        $adminId = $this->adminId;
        $result = OpenvpnLogic::edit($params,$adminId);
        if (true === $result) {
            return $this->success('编辑成功', [], 1, 1);
        }
        return $this->fail(OpenvpnLogic::getError());
    }


    /**
     * @notes 删除openvpn控制器
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/07/04 15:15
     */
    public function delete()
    {
        $params = (new OpenvpnValidate())->post()->goCheck('delete');
        OpenvpnLogic::delete($params);
        return $this->success('删除成功', [], 1, 1);
    }


    /**
     * @notes 获取openvpn控制器详情
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/07/04 15:15
     */
    public function detail()
    {
        $params = (new OpenvpnValidate())->goCheck('detail');
        $result = OpenvpnLogic::detail($params);
        return $this->data($result);
    }


}